package application {
	import flash.display.Sprite;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.system.Capabilities;
	
	public class WindowOpener extends Sprite {
		public function WindowOpener() {
			openCenter();
		}
		
		private function openCenter():void {
			var x:int = Capabilities.screenResolutionX;
			var y:int = Capabilities.screenResolutionY;
			var w:int = 400;
			var h:int = 400;
			
			var winX:int = (x / 2) - (w / 2);
			var winY:int = (y / 2) - (h / 2);
			
			open(winX, winY, w, h);
		}
		
		private function open(x:int, y:int, w:int, h:int):void {
			var jsCode:String = "javascript:void(" +
				"newWin=window.open('s.html'," +
				"'newWindow','width=" + w + ",height=" + h +
				",left=" + x + ",top=" + y + "'));";
			var request:URLRequest = new URLRequest(jsCode);
			navigateToURL(request);
		}
	}
}